import 'package:flutter_application_1/models/recommend_interface.dart';
import 'package:flutter_application_1/models/user_model.dart';

class SongList {
  late final List<SongItem> list;
  SongList(this.list);
  factory SongList.fromJson(List<dynamic> list) {
    return SongList(
      list.map((e) => SongItem.fromJson(e)).toList(),
    );
  }
}

class SongItem implements RecommendInterface {
  late final int id;
  late final int userId;
  late final String coverPictureUrl;
  late final String songUrl;
  late final String cnName;
  late final String enName;
  late final int commentCount;
  late final int thumbUpCount;
  late final int readCount;
  late UserItem user;

  SongItem({
    required this.id,
    required this.userId,
    required this.coverPictureUrl,
    required this.songUrl,
    required this.cnName,
    required this.enName,
    required this.commentCount,
    required this.thumbUpCount,
    required this.readCount,
    required this.user,
  });

  factory SongItem.fromJson(dynamic item) {
    return SongItem(
      id: item["id"],
      userId: item["userId"],
      coverPictureUrl: item["coverPictureUrl"],
      songUrl: item["songUrl"],
      cnName: item["cnName"],
      enName: item["enName"],
      commentCount: item["commentCount"],
      thumbUpCount: item["thumbUpCount"],
      readCount: item["readCount"],
      user: UserItem.fromJson(item["user"]),
    );
  }
}
